package rattlesnake.callback.config.impl;

import rattlesnake.callback.config.CallbackConfig;
import rattlesnake.callback.util.ObjectUtil;
import rattlesnake.callback.util.PropsUtil;
import rattlesnake.callback.util.StringUtil;

import java.util.Properties;

/**
 * @Package: rattlesnake.callback.config.impl
 * @Description: 回调框架中的配置信息
 * @author: liuxin
 * @date: 17/4/11 下午5:45
 */
public class CallbackProperties {

    private static Properties properties = null;

    static {
        String ACTIVE = PropsUtil.loads(CallbackConfig.PRECONFIGPATH).getProperty(CallbackConfig.ACTIVE);
        properties = PropsUtil.loads(CallbackConfig.PATHTEMPLATE.replaceAll("&", ACTIVE));
    }

    public static Integer getServerPort() {
        return PropsUtil.getNumber(properties, CallbackConfig.PORTPATH, CallbackConfig.DEFAULTPORT);
    }

    public static String getProperty(String key) {
        return PropsUtil.getString(properties, key);
    }

    public static Integer getNumber(String key) {
        return PropsUtil.getNumber(properties, key);
    }

    public static boolean getBoolean(String key) {
        return PropsUtil.getBoolean(properties, key);
    }
}
